<%--
 *  File:    MenuShortcut.jsp
 *  @Author: Rael Zhu 
 *  Date:    2003/10/08
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>

<%
  String strModuleName = "UPM";
%>

<%@include file="/inc/PageDefault.inc" %>

<html>
<head>
<title></title>
<script language="JavaScript">

function page_go()
{
  if (frm.privcode.value != "")
  {
    frm.actionname.value = "pageswitch";
    frm.submit();
  }
}

</script>
</head>
<body>

<form name="frm" method="post" action="Dispatcher" target="_self">
  <input type="hidden" name="pagename" value="menushortcut">
  <input type="hidden" name="actionname">
  
  <input type="hidden" name="privcode" value="">
</form>

<%
  String pageURL = (String)session.getAttribute("pageurl");
  if (pageURL == null) pageURL = "";
  
  String pageApp = (String)session.getAttribute("pageapp");
  if (pageApp == null) pageApp = "";
  
  if (pageURL.equals("N/A") || pageApp.equals("N/A"))
  {
%>
    <script language="JavaScript">
    
    alert("<%= message.getMessageDesc("INVALID_PAGE_OR_NO_PRIV") %>");
    parent.menus.focus();
    
    </script> 
<%
    session.removeAttribute("pageurl");
    session.removeAttribute("pageapp");
    return;
  }
%>

<%  
  if (pageURL.length() > 0 && pageApp.length() > 0)
  {
    String curAppName = "";
    Integer curAppCode = (Integer)session.getAttribute("app");
    if (curAppCode == null) curAppCode = new Integer(1);
    
    if (curAppCode.intValue() == 1)
      curAppName = "DMS";
    else if (curAppCode.intValue() == 2)
      curAppName = "BI";
    else if (curAppCode.intValue() == 3)
      curAppName = "CRM";
    else if (curAppCode.intValue() == 4)
      curAppName = "FIM";
    else if (curAppCode.intValue() == 9)
      curAppName = "IMG";
    else if (curAppCode.intValue() == 2000000080)
      curAppName = "ERP";
    
    if (pageApp.equals(curAppName))
    {
      session.removeAttribute("pageurl");
      session.removeAttribute("pageapp");
      
      String moduleCode = (String)session.getAttribute("moduleprivcode");
      if (moduleCode == null) moduleCode = "";
      String parentCode = (String)session.getAttribute("parentprivcode");
      if (parentCode == null) parentCode = "";
      String pageCode = (String)session.getAttribute("privcode");
      if (pageCode == null) pageCode = "";
%>
      <script language="JavaScript">
      
      top.content.location.href = "<%= pageURL + "?" + "languagecode=" + strLanguageCode + "&first="  + moduleCode + "&second=" + parentCode + "&third=" + pageCode + "&" + OvalTools.randomURL() %>";
      
      </script>
<%
    }
    else
    {
%>
      <script language="JavaScript">
      
      for (var i = 0; i < top.topFrame.maintopform.app.options.length; i++)
      {
        if (top.topFrame.maintopform.app.options(i).text == "<%=JspHelper.filterNull( pageApp )%>")
        {
          top.topFrame.maintopform.app.options.selectedIndex = i;
          top.topFrame.App_Changed();
        }
      }
      
      </script>
<%
    }
  }
%>

</body>
</html>
